back to Creeper World
# Immortal-VolcanoVent.crpl
# Created by: nathanaelps
# Created on: 8/28/2020 12:04:36 PM
# ------------------------------------------

$SecondsToHatch:100

$SporeCount:6
$SporeDelay:1 #seconds
$SporeHealthMin:1
$SporeHealthMax:1
$SporePayloadMin:5
$SporePayloadMax:45
$MaxDepth:-1
$MaxRange:-1
$FloodDepth:1

$IsFlipped:0

once @initialize endonce

getTimer0 eq0 if
  @setName
  <-IsFlipped not if
    @checkForFlip
  else
    <-IsDead if
      getTimer2 10 add SetTimer2
      CurrentCoords 0 SetCreeperMax
      @shouldWeRaise
    else
      @shouldWeKill
    endif
  endif
  10 SetTimer0
endif

getTimer2 eq0 if
  @hatch
endif

#-------------------------------

:initialize
  #ShowTraceLog
  0 @setDead
  @setName
  Self CONST_NULLIFIERDAMAGES 0 SetUnitAttribute
  Self CONST_CREATEPZ 0 SetUnitAttribute
  <-SecondsToHatch 30 mul SetTimer2

:hatch
  "CRPLCORE" CurrentCoords CreateUnit ->unit
  <-unit "Immortal-Volcano.crpl" AddScriptToUnit
  <-unit "Immortal-Volcano.crpl" "SporeCount" <-SporeCount SetScriptVar
  <-unit "Immortal-Volcano.crpl" "SporeDelay" <-SporeDelay SetScriptVar
  <-unit "Immortal-Volcano.crpl" "SporeHealthMin" <-SporeHealthMin SetScriptVar
  <-unit "Immortal-Volcano.crpl" "SporeHealthMax" <-SporeHealthMax SetScriptVar
  <-unit "Immortal-Volcano.crpl" "SporePayloadMin" <-SporePayloadMin SetScriptVar
  <-unit "Immortal-Volcano.crpl" "SporePayloadMax" <-SporePayloadMax SetScriptVar
  <-unit "Immortal-Volcano.crpl" "MaxDepth" <-MaxDepth SetScriptVar
  <-unit "Immortal-Volcano.crpl" "MaxRange" <-MaxRange SetScriptVar
  <-unit "Immortal-Volcano.crpl" "FloodDepth" <-FloodDepth SetScriptVar
  Self 0 Destroy



:checkForFlip
  CurrentCoords GetCreeper 0 <-FloodDepth sub lt ->flooded
  <-flooded if 1 ->isFlipped endif

:shouldWeRaise
  CurrentCoords GetCreeper 0 <-FloodDepth sub lt ->flooded
  <-flooded not if 0 @setDead endif

:shouldWeKill
  CurrentCoords GetCreeper 0 <-FloodDepth sub lt ->flooded
  <-IsFlipped <-flooded and if 1 @setDead endif



:setDead
  ->IsDead
  @updateImage
  Self CONST_COUNTSFORVICTORY <-IsDead not SetUnitAttribute
  Self CONST_SUPPORTSDIGITALIS <-IsDead not SetUnitAttribute



:updateImage
  40 ->ImageId
  Self "main" 1.7 1.7 SetImageScale
  <-IsFlipped if <-ImageId 2 add ->ImageId endif
  <-IsDead if <-ImageId 1 add ->ImageId endif
  Self "main" "Custom" <-ImageId Concat SetImage

:setName
  "Volcano emerges in " <-SecondsToHatch "s" Concat Concat SetPopupText